#ifndef __USER_H__
#define __USER_H__

// 1. The chat server has a list of users, whether online or offline
// 2. Chat connection, one user can chat with other uses in a connection
// 3. Each user has a list of friends
// 4. Each user has a list of black list
// 5. User can search other users through name and ID
// 6. User can search other users, and add them to his friend or black list
// 7. User can send invitation to other users to start chat session
// 8. User can accept or deny request 
// 9. User can send messages to other users

// User information
class User {
public
    User(char *name);
    ~User();

    char *getName();
    unsigned int getID();
    unsigned int getCredit();

    // Add and remove a friend
    addFriend(User *user);
    delFriend(char *name);

    // Edit black list
    addBlackList(User *user);
    delBlackList(char *name);

    // User can start a chat session
    void StartChatSession(User *user);
    void EndChatSession();
    
    // Send an invitation
    bool SentInvitation(User *user);
    bool acceptInvitation();

    //send message
    bool sendMessage();

private:

    // Basic user information
    char name[256];
    unsigned int id_;
    unsigned int credit_;

    // Whether online
    int user_status_;

    // Chat information
    User *friend_list_;
    User *black_list_;

    // Chat session list
    ChatSession *chat_session_list_;
};

// Chat session is in which two or more people are chatting
class ChatSession {
public:
    ChatSession(User *user_list);
    ~ChatSession():

    bool AddUser(User *user);
    bool delUser(User *user);
    
private:
    User *users_;
};

//For the back end
class ChatSystem {
Public:
    ChatSystem();
    ~ChatSystem();

    void addUser(char *name);
    void delUser(char *name);

    User *searchUser(char *name);
    User *searchUser(unsigned int id);

    void AddSession(ChatSession *chat_session);
    void EndSession(ChatSession *chat_session);

private:
    User *user_list_;
    ChatSession *chat_session_;
}

#endif

